package test;

/**
 * 秒数转时分秒
 */
public class SecondToHMS {

    public static void main(String[] args) {
        String s = sumSecondToTime(100);
        System.out.println(s);
    }

    /**
     * 功能描述 秒转时分秒
     *
     * @param sumSecond 总秒数
     * @return java.lang.String 返回 “ 01:01:01 ” 格式的时间
     */
    private static String sumSecondToTime(int sumSecond) {
        if (sumSecond <= 0) {
            return "00:00:00";
        }
        int h = sumSecond / 3600;
        int m = (sumSecond - h * 3600) / 60;
        int s = sumSecond - h * 3600 - m * 60;
        String time = "%02d:%02d:%02d";
        time = String.format(time, h, m, s);
        return time;
    }
}
